package com.zlm.user.emp.service.impl;

import com.zlm.common.base.AbstractBaseService;
import com.zlm.common.entity.EmpUserExperienceDO;
import com.zlm.common.enums.CompanyScaleEnum;
import com.zlm.user.emp.dao.EmpUserExperienceDao;
import com.zlm.user.emp.service.EmpUserExperienceService;
import com.zlm.user.emp.util.EmpUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: duyufu
 * @Date: 2019/5/15 10:01
 */
@Service
public class EmpUserExperienceServiceImpl extends AbstractBaseService<EmpUserExperienceDao, EmpUserExperienceDO> implements EmpUserExperienceService {

    @Autowired
    @Override
    public void setBaseDao(EmpUserExperienceDao empUserExperienceDao) {
        this.baseDao = empUserExperienceDao;
    }


    @Override
    public void insertUserExperience(EmpUserExperienceDO empUserExperienceDO) {
        baseDao.insertUserExperience(empUserExperienceDO);
        EmpUtils.updateEmpPerfect(empUserExperienceDO.getEmpId());
    }

    @Override
    public void updateUserExperience(EmpUserExperienceDO empUserExperienceDO) {
        baseDao.updateUserExperience(empUserExperienceDO);
        EmpUtils.updateEmpPerfect(empUserExperienceDO.getEmpId());
    }

    @Override
    public void deleteUserExperience(Integer empId, Integer eid) {
        baseDao.deleteUserExperience(empId,eid);
        EmpUtils.updateEmpPerfect(empId);
    }

    @Override
    public List<EmpUserExperienceDO> queryUserExperience(Integer empId) {
        List<EmpUserExperienceDO> experienceList = baseDao.queryUserExperience(empId);
        for (EmpUserExperienceDO experience : experienceList) {
            if (null != experience.getScale()) {
                experience.setScaleName(CompanyScaleEnum.getNameByCode(experience.getScale()));
            }
        }
        return experienceList;
    }
}
